﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Code.Models;
using System.Text.RegularExpressions;
using Code.BLL.Arithmetic.Comm;

namespace Code.BLL.Arithmetic
{
    internal class GDKLSF : LotteryTypeProduct
    {
        public override PlayTypeProduct GetPlayType(Models.PlayType_E playType)
        {
            PlayTypeProduct product;

            switch (playType)
            {

                case PlayType_E.RenXuanEr:
                    return product = new RenXuanEr(RenXuanEr);

                case PlayType_E.RenXuanSan:
                    return product = new RenXuanSan(RenXuanSan);

                case PlayType_E.RenXuanSi:
                    return product = new RenXuanSi(RenXuanSi);

                case PlayType_E.RenXuanWu:
                    return product = new RenXuanWu(RenXuanWu);

                case PlayType_E.RenErDanTuo:
                    return product = new RenErDanTuo(RenErDanTuo);

                case PlayType_E.RenSanDanTuo:
                    return product = new RenSanDanTuo(RenSanDanTuo);

                case PlayType_E.RenSiDanTuo:
                    return product = new RenSiDanTuo(RenSiDanTuo);

                case PlayType_E.RenWuDanTuo:
                    return product = new RenWuDanTuo(RenWuDanTuo);

                case PlayType_E.QianYiShuTou:
                    return product = new QianYiShuTou(QianYiShuTou);

                case PlayType_E.QianYiHongTou:
                    return product = new QianYiHongTou(QianYiHongTou);

                case PlayType_E.XuanErLianZhi:
                    return product = new XuanErLianZhi(XuanErLianZhi);

                case PlayType_E.XuanErLianZu:
                    return product = new XuanErLianZu(XuanErLianZu);

                case PlayType_E.XuanSanQianZhi:
                    return product = new XuanSanQianZhi(XuanSanQianZhi);

                case PlayType_E.XuanSanQianZu:
                    return product = new XuanSanQianZu(XuanSanQianZu);

                case PlayType_E.XuanErLianZuDanTuo:
                    return product = new XuanErLianZuDanTuo(XuanErLianZuDanTuo);

                case PlayType_E.XuanSanQianZuDanTuo:
                    return product = new XuanSanQianZuDanTuo(XuanSanQianZuDanTuo);

                default:
                    throw new Exception("广东快乐十分无当前玩法:" + playType);
            }
            product.lotteryType = LotteryType.GDKLSF;
            return product;
        }
        private Regex RenXuanEr = new Regex(@"^(?![\dab]{0,}(?<num>[\dab])[\dab]{0,}\k<num>)[\dab]{1,11}(,(?![\dab]{0,}(?<num>[\dab])[\dab]{0,}\k<num>)[\dab]{1,11}){1}$", RegexOptions.Compiled);
        private Regex RenXuanSan = new Regex(@"^(?![\dab]{0,}(?<num>[\dab])[\dab]{0,}\k<num>)[\dab]{1,11}(,(?![\dab]{0,}(?<num>[\dab])[\dab]{0,}\k<num>)[\dab]{1,11}){1}$", RegexOptions.Compiled);
        private Regex RenXuanSi = new Regex(@"^(?![\dab]{0,}(?<num>[\dab])[\dab]{0,}\k<num>)[\dab]{1,11}(,(?![\dab]{0,}(?<num>[\dab])[\dab]{0,}\k<num>)[\dab]{1,11}){1}$", RegexOptions.Compiled);
        private Regex RenXuanWu = new Regex(@"^(?![\dab]{0,}(?<num>[\dab])[\dab]{0,}\k<num>)[\dab]{1,11}(,(?![\dab]{0,}(?<num>[\dab])[\dab]{0,}\k<num>)[\dab]{1,11}){1}$", RegexOptions.Compiled);
        private Regex RenErDanTuo = new Regex(@"^(?![\dab]{0,}(?<num>[\dab])[\dab]{0,}\k<num>)[\dab]{1,11}(,(?![\dab]{0,}(?<num>[\dab])[\dab]{0,}\k<num>)[\dab]{1,11}){1}$", RegexOptions.Compiled);
        private Regex RenSanDanTuo = new Regex(@"^(?![\dab]{0,}(?<num>[\dab])[\dab]{0,}\k<num>)[\dab]{1,11}(,(?![\dab]{0,}(?<num>[\dab])[\dab]{0,}\k<num>)[\dab]{1,11}){1}$", RegexOptions.Compiled);
        private Regex RenSiDanTuo = new Regex(@"^(?![\dab]{0,}(?<num>[\dab])[\dab]{0,}\k<num>)[\dab]{1,11}(,(?![\dab]{0,}(?<num>[\dab])[\dab]{0,}\k<num>)[\dab]{1,11}){1}$", RegexOptions.Compiled);
        private Regex RenWuDanTuo = new Regex(@"^(?![\dab]{0,}(?<num>[\dab])[\dab]{0,}\k<num>)[\dab]{1,11}(,(?![\dab]{0,}(?<num>[\dab])[\dab]{0,}\k<num>)[\dab]{1,11}){1}$", RegexOptions.Compiled);
        private Regex QianYiShuTou = new Regex(@"^(?![\dab]{0,}(?<num>[\dab])[\dab]{0,}\k<num>)[\dab]{1,11}(,(?![\dab]{0,}(?<num>[\dab])[\dab]{0,}\k<num>)[\dab]{1,11}){1}$", RegexOptions.Compiled);
        private Regex QianYiHongTou = new Regex(@"^(?![\dab]{0,}(?<num>[\dab])[\dab]{0,}\k<num>)[\dab]{1,11}(,(?![\dab]{0,}(?<num>[\dab])[\dab]{0,}\k<num>)[\dab]{1,11}){1}$", RegexOptions.Compiled);
        private Regex XuanErLianZhi = new Regex(@"^(?![\dab]{0,}(?<num>[\dab])[\dab]{0,}\k<num>)[\dab]{1,11}(,(?![\dab]{0,}(?<num>[\dab])[\dab]{0,}\k<num>)[\dab]{1,11}){1}$", RegexOptions.Compiled);
        private Regex XuanErLianZu = new Regex(@"^(?![\dab]{0,}(?<num>[\dab])[\dab]{0,}\k<num>)[\dab]{1,11}(,(?![\dab]{0,}(?<num>[\dab])[\dab]{0,}\k<num>)[\dab]{1,11}){1}$", RegexOptions.Compiled);
        private Regex XuanSanQianZu = new Regex(@"^(?![\dab]{0,}(?<num>[\dab])[\dab]{0,}\k<num>)[\dab]{1,11}(,(?![\dab]{0,}(?<num>[\dab])[\dab]{0,}\k<num>)[\dab]{1,11}){1}$", RegexOptions.Compiled);
        private Regex XuanErLianZuDanTuo = new Regex(@"^(?![\dab]{0,}(?<num>[\dab])[\dab]{0,}\k<num>)[\dab]{1,11}(,(?![\dab]{0,}(?<num>[\dab])[\dab]{0,}\k<num>)[\dab]{1,11}){1}$", RegexOptions.Compiled);
        private Regex XuanSanQianZuDanTuo = new Regex(@"^(?![\dab]{0,}(?<num>[\dab])[\dab]{0,}\k<num>)[\dab]{1,11}(,(?![\dab]{0,}(?<num>[\dab])[\dab]{0,}\k<num>)[\dab]{1,11}){1}$", RegexOptions.Compiled);
        private Regex LianSanQianZhi = new Regex(@"^(?![\dab]{0,}(?<num>[\dab])[\dab]{0,}\k<num>)[\dab]{1,11}(,(?![\dab]{0,}(?<num>[\dab])[\dab]{0,}\k<num>)[\dab]{1,11}){1}$", RegexOptions.Compiled);
        private Regex XuanSanQianZhi = new Regex(@"^(?![\dab]{0,}(?<num>[\dab])[\dab]{0,}\k<num>)[\dab]{1,11}(,(?![\dab]{0,}(?<num>[\dab])[\dab]{0,}\k<num>)[\dab]{1,11}){1}$", RegexOptions.Compiled);
    }




    /// <summary>
    /// 任选二
    /// </summary>
    internal class RenXuanEr : PlayTypeProduct
    {
        private string _OpenCode;
        private PlayType_E PlayType { get; set; }
        /// <summary>
        /// 数字的构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        public RenXuanEr(Regex regDouble)
            : base(regDouble)
        {
            PlayType = PlayType_E.RenXuanEr;
        }
        public RenXuanEr(Regex regDouble, PlayType_E playType)
            : base(regDouble)
        {
            PlayType = playType;
        }

        protected override IEnumerable<string> _GetWinNums(string userChoseNumber, string openCode)
        {
            _OpenCode = PlayType_E.RenXuanEr.GetOpenCode(openCode, base.lotteryType);
            if (userChoseNumber == null || userChoseNumber == "")
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");

            List<string> winNums = new List<string>();
            List<string> selectnum = new List<string>();
            List<string> opennum = new List<string>();
            var list = userChoseNumber.Split(new string[] { ",", "," }, StringSplitOptions.RemoveEmptyEntries);
            var num1 = list[0].ToString();
            String[] str1 = num1.Split(' ');
            int number = 0;
            foreach (var item in list)
            {
                number++;
            }
            if (number == 1)
            {
                if (str1.Length < 2)
                {
                    throw new ArgumentNullException("userChoseNumber", "参数格式不正确");
                }
                for (int i = 0; i < str1.Length; i++)
                {
                    for (int j = 0; j < str1.Length; j++)
                    {
                        if (str1[i].ToString() != str1[j].ToString())
                        {
                            if (j != i)
                            {
                                selectnum.Add(str1[i].ToString() + "," + str1[j].ToString());
                            }
                        }
                    }
                }
            }
            else
            {
                userChoseNumber = userChoseNumber.Replace(',', ' ');
                var str2 = userChoseNumber.Split(' ');
                if (str2.Length < 2)
                {
                    throw new ArgumentNullException("userChoseNumber", "参数格式不正确");
                }
                for (int i = 0; i < str2.Length; i++)
                {
                    for (int j = 0; j < str2.Length; j++)
                    {
                        if (str2[i].ToString() != str2[j].ToString())
                        {

                            selectnum.Add(str2[i].ToString() + "," + str2[j].ToString());

                        }
                    }
                }
            }
            var open = openCode.Split(',');
            for (int i = 0; i < open.Length; i++)
            {
                for (int j = 0; j < open.Length; j++)
                {
                    if (open[i].ToString() != open[j].ToString())
                    {
                        if (j > i)
                        {
                            opennum.Add(open[i].ToString() + "," + open[j].ToString());

                        }


                    }
                }
            }

            for (int i = 0; i < opennum.Count; i++)
            {
                for (int j = 0; j < selectnum.Count; j++)
                {
                    if (opennum[i].ToString() == selectnum[j].ToString())
                    {
                        winNums.Add(opennum[i].ToString());
                    }
                }
            }

            return winNums;
        }
        protected override int _GetNumCount(string userChoseNumber)
        {
            int result = 0;
            var list = userChoseNumber.Split(new string[] { ",", "," }, StringSplitOptions.RemoveEmptyEntries);
            var num1 = list[0].ToString();
            String[] str1 = num1.Split(' ');
            int count = 0;
            int number = 0;
            foreach (var item in list)
            {
                number++;
            }
            if (number == 1)
            {
                count = str1.Length;
            }
            else
            {
                var num2 = list[1].ToString();
                string[] str2 = num2.Split(' ');
                count = str1.Length + str2.Length;
            }

            var n = 1;
            for (var a = count - 1; a <= count; a++)
            {
                n = n * a;
            }
            var m = 1;
            for (var i = 1; i < 3; i++)
            {
                m = m * i;
            }
            result = n / m;
            return result;
        }

        protected override List<string> _GetChoseNumberList(string userChoseNumber)
        {
            //if (userChoseNumber == null)
            //    throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            //userChoseNumber = userChoseNumber.Replace(',',' ');
            //string [] str1 = userChoseNumber.Split(' ');
            //Split sp=new Split();
            //base.ChoseNumberList = sp.Er(str1,1);
            //return base.ChoseNumberList;
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            if (base.lotteryType == LotteryType.TC11X5)
            {
                userChoseNumber = userChoseNumber.Replace("10", "a").Replace("11", "b").Replace("0", "").Replace(" ", "");
                base.ChoseNumberList = ManipulateNumber.GetNumList(userChoseNumber).Select(p => string.Join(" ", p.Select(pp => pp == 'a' || pp == 'b' ? pp.ToString() : "0" + pp).ToArray()).Replace("b", "11").Replace("a", "10")).ToList();
            }
            else
                base.ChoseNumberList = ManipulateNumber.GetNumList(userChoseNumber);
            return base.ChoseNumberList;
        }
    }


    /// <summary>
    /// 任选三
    /// </summary>
    internal class RenXuanSan : PlayTypeProduct
    {
        private string _OpenCode;
        private PlayType_E PlayType { get; set; }
        /// <summary>
        /// 数字的构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        public RenXuanSan(Regex regDouble)
            : base(regDouble)
        {
            PlayType = PlayType_E.RenXuanSan;
        }
        public RenXuanSan(Regex regDouble, PlayType_E playType)
            : base(regDouble)
        {
            PlayType = playType;
        }

        protected override IEnumerable<string> _GetWinNums(string userChoseNumber, string openCode)
        {
            _OpenCode = PlayType_E.RenXuanSan.GetOpenCode(openCode, base.lotteryType);
            if (userChoseNumber == null || userChoseNumber == "")
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            List<string> winNums = new List<string>();
            List<string> selectnum = new List<string>();
            List<string> opennum = new List<string>();
            var num = 0;
            var list = userChoseNumber.Split(new string[] { ",", "," }, StringSplitOptions.RemoveEmptyEntries);
            foreach (var item in list)
            {
                num++;
            }
            if (num == 1)
            {
                var str1 = list[0].Split(' ');
                if (str1.Length < 3)
                {
                    throw new ArgumentNullException("userChoseNumber", "参数格式不正确");
                }
                for (int i = 0; i < str1.Length; i++)
                {
                    for (int j = 0; j < str1.Length; j++)
                    {
                        for (int x = 0; x < str1.Length; x++)
                        {
                            if (str1[i].ToString() != str1[j].ToString() && str1[i].ToString() != str1[x].ToString() && str1[x].ToString() != str1[j].ToString())
                            {

                                selectnum.Add(str1[i].ToString() + "," + str1[j].ToString() + "," + str1[x].ToString());

                            }
                        }
                    }
                }
            }
            else
            {
                userChoseNumber = userChoseNumber.Replace(',', ' ');
                var str1 = userChoseNumber.Split(' ');
                if (str1.Length < 2)
                {
                    throw new ArgumentNullException("userChoseNumber", "参数格式不正确");
                }
                for (int i = 0; i < str1.Length; i++)
                {
                    for (int j = 0; j < str1.Length; j++)
                    {
                        for (int x = 0; x < str1.Length; x++)
                        {
                            if (str1[i].ToString() != str1[j].ToString() && str1[i].ToString() != str1[x].ToString() && str1[x].ToString() != str1[j].ToString())
                            {

                                selectnum.Add(str1[i].ToString() + "," + str1[j].ToString() + "," + str1[x].ToString());

                            }
                        }
                    }
                }

            }
            string[] code = openCode.Split(',');
            for (int i = 0; i < code.Length; i++)
            {
                for (int j = 0; j < code.Length; j++)
                {
                    for (int x = 0; x < code.Length; x++)
                    {
                        if (code[i].ToString() != code[j].ToString() && code[i].ToString() != code[x].ToString() && code[x].ToString() != code[j].ToString())
                        {
                            if (j > i && x > j)
                            {
                                opennum.Add(code[i].ToString() + "," + code[j].ToString() + "," + code[x].ToString());

                            }
                        }
                    }
                }
            }
            for (int i = 0; i < opennum.Count(); i++)
            {
                for (int j = 0; j < selectnum.Count(); j++)
                {
                    if (opennum[i].ToString() == selectnum[j].ToString())
                    {
                        winNums.Add(opennum[i].ToString());
                    }
                }
            }


            return winNums;
        }
        protected override int _GetNumCount(string userChoseNumber)
        {
            int result = 0;
            var list = userChoseNumber.Split(new string[] { ", ", "," }, StringSplitOptions.RemoveEmptyEntries);
            var num1 = list[0].ToString();
            String[] str1 = num1.Split(' ');
            int count = 0;
            int number = 0;
            foreach (var item in list)
            {
                number++;
            }
            if (number == 1)
            {
                count = str1.Length;
            }
            else
            {
                var num2 = list[1].ToString();
                string[] str2 = num2.Split(' ');
                count = str1.Length + str2.Length;
            }
            var n = 1;
            for (var a = count - 2; a <= count; a++)
            {
                n = n * a;
            }
            var m = 1;
            for (var i = 1; i < 4; i++)
            {
                m = m * i;
            }
            result = n / m;

            return result;
        }
        protected override List<string> _GetChoseNumberList(string userChoseNumber)
        {
            //userChoseNumber = userChoseNumber.Replace(',', ' ');
            //string[] str1 = userChoseNumber.Split(' ');
            //Split sp = new Split();
            //base.ChoseNumberList = sp.San(str1, 1);
            //return base.ChoseNumberList;
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            if (base.lotteryType == LotteryType.TC11X5)
            {
                userChoseNumber = userChoseNumber.Replace("10", "a").Replace("11", "b").Replace("0", "").Replace(" ", "");
                base.ChoseNumberList = ManipulateNumber.GetNumList(userChoseNumber).Select(p => string.Join(" ", p.Select(pp => pp == 'a' || pp == 'b' ? pp.ToString() : "0" + pp).ToArray()).Replace("b", "11").Replace("a", "10")).ToList();
            }
            else
                base.ChoseNumberList = ManipulateNumber.GetNumList(userChoseNumber);
            return base.ChoseNumberList;
        }
    }



    /// <summary>
    ///任选四
    /// </summary>
    internal class RenXuanSi : PlayTypeProduct
    {
        private string _OpenCode;
        private PlayType_E PlayType { get; set; }
        /// <summary>
        /// 数字的构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        public RenXuanSi(Regex regDouble)
            : base(regDouble)
        {
            PlayType = PlayType_E.RenXuanSi;
        }
        public RenXuanSi(Regex regDouble, PlayType_E playType)
            : base(regDouble)
        {
            PlayType = playType;
        }

        protected override IEnumerable<string> _GetWinNums(string userChoseNumber, string openCode)
        {
            _OpenCode = PlayType_E.RenXuanSi.GetOpenCode(openCode, base.lotteryType);
            if (userChoseNumber == null || userChoseNumber == "")
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            List<string> winNums = new List<string>();
            List<string> selectnum = new List<string>();
            List<string> opennum = new List<string>();
            var num = 0;
            var list = userChoseNumber.Split(new string[] { ",", "," }, StringSplitOptions.RemoveEmptyEntries);
            foreach (var item in list)
            {
                num++;
            }
            if (num == 1)
            {
                var str1 = list[0].Split(' ');
                if (str1.Length < 4)
                {
                    throw new ArgumentNullException("userChoseNumber", "参数格式不正确");
                }
                for (int i = 0; i < str1.Length; i++)
                {
                    for (int j = 0; j < str1.Length; j++)
                    {
                        for (int x = 0; x < str1.Length; x++)
                        {
                            for (int y = 0; y < str1.Length; y++)
                            {
                                if (str1[i].ToString() != str1[j].ToString() && str1[i].ToString() != str1[x].ToString() && str1[x].ToString() != str1[j].ToString() && str1[i].ToString() != str1[y].ToString() && str1[j].ToString() != str1[y].ToString() && str1[x].ToString() != str1[y].ToString())
                                {

                                    selectnum.Add(list[i].ToString() + "," + list[j].ToString() + "," + str1[x].ToString() + "," + str1[y].ToString());

                                }
                            }

                        }
                    }
                }
            }
            else
            {
                userChoseNumber = userChoseNumber.Replace(',', ' ');
                var res = userChoseNumber.Split(' ');

                if (res.Length < 4)
                {
                    throw new ArgumentNullException("userChoseNumber", "参数格式不正确");
                }
                for (int i = 0; i < res.Length; i++)
                {
                    for (int j = 0; j < res.Length; j++)
                    {
                        for (int x = 0; x < res.Length; x++)
                        {
                            for (int y = 0; y < res.Length; y++)
                            {
                                if (res[i].ToString() != res[j].ToString() && res[i].ToString() != res[x].ToString() && res[x].ToString() != res[j].ToString() && res[i].ToString() != res[y].ToString() && res[j].ToString() != res[y].ToString() && res[x].ToString() != res[y].ToString())
                                {
                                    selectnum.Add(res[i].ToString() + "," + res[j].ToString() + "," + res[x].ToString() + "," + res[y].ToString());
                                }
                            }

                        }
                    }
                }

            }
            string[] code = openCode.Split(',');
            for (int i = 0; i < code.Length; i++)
            {
                for (int j = 0; j < code.Length; j++)
                {
                    for (int x = 0; x < code.Length; x++)
                    {
                        for (int y = 0; y < code.Length; y++)
                        {
                            if (code[i].ToString() != code[j].ToString() && code[i].ToString() != code[x].ToString() && code[x].ToString() != code[j].ToString() && code[i].ToString() != code[y].ToString() && code[j].ToString() != code[y].ToString() && code[x].ToString() != code[y].ToString())
                            {
                                if (x > j && j > i && y > x)
                                {
                                    opennum.Add(code[i].ToString() + "," + code[j].ToString() + "," + code[x].ToString() + "," + code[y].ToString());
                                }
                            }
                        }

                    }
                }
            }
            for (int i = 0; i < opennum.Count(); i++)
            {
                for (int j = 0; j < selectnum.Count(); j++)
                {
                    if (opennum[i].ToString() == selectnum[j].ToString())
                    {
                        winNums.Add(opennum[i].ToString());
                    }
                }
            }
            return winNums;
        }
        protected override int _GetNumCount(string userChoseNumber)
        {
            int result = 0;
            var list = userChoseNumber.Split(new string[] { ", ", "," }, StringSplitOptions.RemoveEmptyEntries);
            var num1 = list[0].ToString();
            String[] str1 = num1.Split(' ');
            int count = 0;
            int number = 0;
            foreach (var item in list)
            {
                number++;
            }
            if (number == 1)
            {
                count = str1.Length;
            }
            else
            {
                var num2 = list[1].ToString();
                string[] str2 = num2.Split(' ');
                count = str1.Length + str2.Length;
            }
            var n = 1;
            for (var a = count - 3; a <= count; a++)
            {
                n = n * a;
            }
            var m = 1;
            for (var i = 1; i < 5; i++)
            {
                m = m * i;
            }
            result = n / m;

            return result;
        }
        protected override List<string> _GetChoseNumberList(string userChoseNumber)
        {
            //userChoseNumber = userChoseNumber.Replace(',', ' ');
            //string[] str1 = userChoseNumber.Split(' ');
            //Split sp = new Split();
            //base.ChoseNumberList = sp.Si(str1, 1);
            //return base.ChoseNumberList;
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            if (base.lotteryType == LotteryType.TC11X5)
            {
                userChoseNumber = userChoseNumber.Replace("10", "a").Replace("11", "b").Replace("0", "").Replace(" ", "");
                base.ChoseNumberList = ManipulateNumber.GetNumList(userChoseNumber).Select(p => string.Join(" ", p.Select(pp => pp == 'a' || pp == 'b' ? pp.ToString() : "0" + pp).ToArray()).Replace("b", "11").Replace("a", "10")).ToList();
            }
            else
                base.ChoseNumberList = ManipulateNumber.GetNumList(userChoseNumber);
            return base.ChoseNumberList;
        }

    }



    /// <summary>
    /// 任选五
    /// </summary>
    internal class RenXuanWu : PlayTypeProduct
    {
        private string _OpenCode;
        private PlayType_E PlayType { get; set; }
        /// <summary>
        /// 数字的构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        public RenXuanWu(Regex regDouble)
            : base(regDouble)
        {
            PlayType = PlayType_E.RenXuanWu;
        }
        public RenXuanWu(Regex regDouble, PlayType_E playType)
            : base(regDouble)
        {
            PlayType = playType;
        }
        protected override IEnumerable<string> _GetWinNums(string userChoseNumber, string openCode)
        {
            _OpenCode = PlayType_E.RenXuanWu.GetOpenCode(openCode, base.lotteryType);
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");

            List<string> winNums = new List<string>();
            List<string> selectnum = new List<string>();
            List<string> opennum = new List<string>();
            var num = 0;
            var list = userChoseNumber.Split(new string[] { ",", "," }, StringSplitOptions.RemoveEmptyEntries);
            foreach (var item in list)
            {
                num++;
            }
            if (num == 1)
            {
                var str1 = list[0].Split(' ');
                if (str1.Length < 5)
                {
                    throw new ArgumentNullException("userChoseNumber", "参数格式不正确");
                }
                for (int i = 0; i < str1.Length; i++)
                {
                    for (int j = 0; j < str1.Length; j++)
                    {
                        for (int x = 0; x < str1.Length; x++)
                        {
                            for (int y = 0; y < str1.Length; y++)
                            {
                                for (int z = 0; z < str1.Length; z++)
                                {
                                    if (str1[i].ToString() != str1[j].ToString() && str1[i].ToString() != str1[x].ToString() && str1[x].ToString() != str1[j].ToString() && str1[i].ToString() != str1[y].ToString() && str1[j].ToString() != str1[y].ToString() && str1[x].ToString() != str1[y].ToString() && str1[i].ToString() != str1[z].ToString() && str1[j].ToString() != str1[z].ToString() && str1[x].ToString() != str1[z].ToString() && str1[y].ToString() != str1[z].ToString())
                                    {

                                        selectnum.Add(str1[i].ToString() + "," + str1[j].ToString() + "," + str1[x].ToString() + "," + str1[y].ToString() + "," + str1[z].ToString());

                                    }
                                }

                            }

                        }
                    }
                }
            }
            else
            {
                userChoseNumber = userChoseNumber.Replace(',', ' ');
                var str1 = userChoseNumber.Split(' ');
                if (str1.Length < 5)
                {
                    throw new ArgumentNullException("userChoseNumber", "参数格式不正确");
                }
                for (int i = 0; i < str1.Length; i++)
                {
                    for (int j = 0; j < str1.Length; j++)
                    {
                        for (int x = 0; x < str1.Length; x++)
                        {
                            for (int y = 0; y < str1.Length; y++)
                            {
                                for (int z = 0; z < str1.Length; z++)
                                {
                                    if (str1[i].ToString() != str1[j].ToString() && str1[i].ToString() != str1[x].ToString() && str1[x].ToString() != str1[j].ToString() && str1[i].ToString() != str1[y].ToString() && str1[j].ToString() != str1[y].ToString() && str1[x].ToString() != str1[y].ToString() && str1[i].ToString() != str1[z].ToString() && str1[j].ToString() != str1[z].ToString() && str1[x].ToString() != str1[z].ToString() && str1[y].ToString() != str1[z].ToString())
                                    {

                                        selectnum.Add(str1[i].ToString() + "," + str1[j].ToString() + "," + str1[x].ToString() + "," + str1[y].ToString() + "," + str1[z].ToString());

                                    }
                                }

                            }

                        }
                    }
                }

            }
            string[] code = openCode.Split(',');
            for (int i = 0; i < code.Length; i++)
            {
                for (int j = 0; j < code.Length; j++)
                {
                    for (int x = 0; x < code.Length; x++)
                    {
                        for (int y = 0; y < code.Length; y++)
                        {
                            for (int z = 0; z < code.Length; z++)
                            {
                                if (code[i].ToString() != code[j].ToString() && code[i].ToString() != code[x].ToString() && code[x].ToString() != code[j].ToString() && code[i].ToString() != code[y].ToString() && code[j].ToString() != code[y].ToString() && code[x].ToString() != code[y].ToString() && code[i].ToString() != code[z].ToString() && code[j].ToString() != code[z].ToString() && code[x].ToString() != code[z].ToString() && code[y].ToString() != code[z].ToString())
                                {
                                    if (x > j && j > i && y > x && z > y)
                                    {
                                        opennum.Add(code[i].ToString() + "," + code[j].ToString() + "," + code[x].ToString() + "," + code[y].ToString() + "," + code[z].ToString());

                                    }


                                }
                            }

                        }

                    }
                }
            }
            for (int i = 0; i < opennum.Count(); i++)
            {
                for (int j = 0; j < selectnum.Count(); j++)
                {
                    if (opennum[i].ToString() == selectnum[j].ToString())
                    {
                        winNums.Add(opennum[i].ToString());
                    }
                }
            }
            return winNums;
        }
        protected override int _GetNumCount(string userChoseNumber)
        {
            int result = 0;
            var list = userChoseNumber.Split(new string[] { ", ", "," }, StringSplitOptions.RemoveEmptyEntries);
            var num1 = list[0].ToString();
            String[] str1 = num1.Split(' ');
            int count = 0;
            int number = 0;
            foreach (var item in list)
            {
                number++;
            }
            if (number == 1)
            {
                count = str1.Length;
            }
            else
            {
                var num2 = list[1].ToString();
                string[] str2 = num2.Split(' ');
                count = str1.Length + str2.Length;
            }
            var n = 1;
            for (var a = count - 4; a <= count; a++)
            {
                n = n * a;
            }
            var m = 1;
            for (var i = 1; i < 6; i++)
            {
                m = m * i;
            }
            result = n / m;

            return result;
        }
        protected override List<string> _GetChoseNumberList(string userChoseNumber)
        {
            //userChoseNumber = userChoseNumber.Replace(',', ' ');
            //string[] str1 = userChoseNumber.Split(' ');
            //for (int i = 0; i < str1.Length; i++)
            //{
            //    for (int j = 0; j < str1.Length; j++)
            //    {
            //        for (int x = 0; x < str1.Length; x++)
            //        {
            //            for (int y = 0; y < str1.Length; y++)
            //            {
            //                for (int z = 0; z < str1.Length; z++)
            //                {
            //                    if (str1[i].ToString() != str1[j].ToString() && str1[i].ToString() != str1[x].ToString() && str1[x].ToString() != str1[j].ToString() && str1[i].ToString() != str1[y].ToString() && str1[j].ToString() != str1[y].ToString() && str1[x].ToString() != str1[y].ToString() && str1[i].ToString() != str1[z].ToString() && str1[j].ToString() != str1[z].ToString() && str1[x].ToString() != str1[z].ToString() && str1[y].ToString() != str1[z].ToString())
            //                    {

            //                        base.ChoseNumberList.Add(str1[i].ToString() + "," + str1[j].ToString() + "," + str1[x].ToString() + "," + str1[y].ToString() + "," + str1[z].ToString());

            //                    }
            //                }

            //            }

            //        }
            //    }
            //}
            //return base.ChoseNumberList;
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            if (base.lotteryType == LotteryType.TC11X5)
            {
                userChoseNumber = userChoseNumber.Replace("10", "a").Replace("11", "b").Replace("0", "").Replace(" ", "");
                base.ChoseNumberList = ManipulateNumber.GetNumList(userChoseNumber).Select(p => string.Join(" ", p.Select(pp => pp == 'a' || pp == 'b' ? pp.ToString() : "0" + pp).ToArray()).Replace("b", "11").Replace("a", "10")).ToList();
            }
            else
                base.ChoseNumberList = ManipulateNumber.GetNumList(userChoseNumber);
            return base.ChoseNumberList;
        }
    }



    /// <summary>
    /// 任二胆拖
    /// </summary>
    internal class RenErDanTuo : PlayTypeProduct
    {
        private string _OpenCode;
        private PlayType_E PlayType { get; set; }
        /// <summary>
        /// 数字的构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        public RenErDanTuo(Regex regDouble)
            : base(regDouble)
        {
            PlayType = PlayType_E.RenErDanTuo;
        }
        public RenErDanTuo(Regex regDouble, PlayType_E playType)
            : base(regDouble)
        {
            PlayType = playType;
        }
        protected override IEnumerable<string> _GetWinNums(string userChoseNumber, string openCode)
        {
            _OpenCode = PlayType_E.RenErDanTuo.GetOpenCode(openCode, base.lotteryType);
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");

            List<string> winNums = new List<string>();
            List<string> selectnum = new List<string>();
            List<string> opennum = new List<string>();
            var num = 0;
            var list = userChoseNumber.Split(new string[] { ",", "," }, StringSplitOptions.RemoveEmptyEntries);
            foreach (var item in list)
            {
                num++;
            }
            if (num == 1)
            {
                throw new ArgumentException("参数数格式不正确", "userChoseNumber");
            }
            else
            {

                var num1 = list[0].ToString();

                var code = openCode.Split(new string[] { ",", "," }, StringSplitOptions.RemoveEmptyEntries);
                for (int i = 0; i < code.Length; i++)
                {
                    if (num1 == code[i].ToString())
                    {
                        var num2 = list[1].ToString();
                        string[] str2 = num2.Split(' ');
                        for (int j = 0; j < str2.Length; j++)
                        {
                            for (int x = 0; x < code.Length; x++)
                            {
                                if (str2[j].ToString() == code[x].ToString())
                                {
                                    winNums.Add(num1 + "," + str2[j].ToString());
                                }
                            }
                        }
                    }
                   
                }
            }

            return winNums;
        }
        protected override int _GetNumCount(string userChoseNumber)
        {
            var list = userChoseNumber.Split(new string[] { ", ", "," }, StringSplitOptions.RemoveEmptyEntries);
            var num1 = list[0].ToString();
            String[] str1 = num1.Split(' ');
            var num2 = list[1].ToString();
            string[] str2 = num2.Split(' ');
            int count = str2.Length;
            if (str1.Count() > 1 || str2.Count() + str1.Count() < 3 || str1.Count() == 0)
            {
                throw new ValidateException("选择的号码不正确！");
            }
            return count;
        }
        protected override List<string> _GetChoseNumberList(string userChoseNumber)
        {
            //if (userChoseNumber == null)
            //    throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            //var list = userChoseNumber.Split(',');
            //var str2 = list[1].Split(' ');
            //for (int i = 0; i < str2.Length; i++)
            //{
            //    base.ChoseNumberList.Add(list[0].ToString()+","+str2[i].ToString());
            //}
            //return base.ChoseNumberList;
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            if (base.lotteryType == LotteryType.TC11X5)
            {
                userChoseNumber = userChoseNumber.Replace("10", "a").Replace("11", "b").Replace("0", "").Replace(" ", "");
                base.ChoseNumberList = ManipulateNumber.GetNumList(userChoseNumber).Select(p => string.Join(" ", p.Select(pp => pp == 'a' || pp == 'b' ? pp.ToString() : "0" + pp).ToArray()).Replace("b", "11").Replace("a", "10")).ToList();
            }
            else
                base.ChoseNumberList = ManipulateNumber.GetNumList(userChoseNumber);
            return base.ChoseNumberList;
        }
    }



    /// <summary>
    /// "任三胆拖
    /// </summary>
    internal class RenSanDanTuo : PlayTypeProduct
    {
        private string _OpenCode;
        private PlayType_E PlayType { get; set; }
        /// <summary>
        /// 数字的构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        public RenSanDanTuo(Regex regDouble)
            : base(regDouble)
        {
            PlayType = PlayType_E.RenSanDanTuo;
        }
        public RenSanDanTuo(Regex regDouble, PlayType_E playType)
            : base(regDouble)
        {
            PlayType = playType;
        }
        protected override IEnumerable<string> _GetWinNums(string userChoseNumber, string openCode)
        {
            _OpenCode = PlayType_E.RenSanDanTuo.GetOpenCode(openCode, base.lotteryType);
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            List<string> winNums = new List<string>();
            List<string> selectnum = new List<string>();
            List<string> opennum = new List<string>();
            var num = 0;
            var list = userChoseNumber.Split(new string[] { ",", "," }, StringSplitOptions.RemoveEmptyEntries);
            var code = openCode.Split(new string[] { ",", "," }, StringSplitOptions.RemoveEmptyEntries);
            foreach (var item in list)
            {
                num++;
            }
            if (num == 1)
            {
                throw new ArgumentException("参数数格式不正确", "userChoseNumber");
            }
            else
            {
                var num1 = list[0].ToString();
                var str1 = num1.Split(' ');
                var num2 = list[1].ToString();
                var str2 = num2.Split(' ');


                if (str1.Length == 1)
                {
                    if (str2.Length < 2)
                    {
                        throw new ArgumentException("参数数格式不正确", "userChoseNumber");
                    }


                    for (int z = 0; z < code.Length; z++)
                    {
                        if (num1 == code[z].ToString())
                        {
                            for (int i = 0; i < code.Length; i++)
                            {
                                for (int j = 0; j < code.Length; j++)
                                {
                                    if (code[i].ToString() != code[j].ToString())
                                    {
                                        if (j > i)
                                        {
                                            opennum.Add(code[i].ToString() + "," + code[j].ToString());
                                        }
                                    }
                                }
                            }
                            for (int i = 0; i < str2.Length; i++)
                            {
                                for (int j = 0; j < str2.Length; j++)
                                {
                                    if (str2[i].ToString() != str2[j].ToString())
                                    {
                                        selectnum.Add(str2[i].ToString() + "," + str2[j].ToString());
                                    }
                                }
                            }
                            for (int i = 0; i < opennum.Count; i++)
                            {
                                for (int j = 0; j < selectnum.Count; j++)
                                {
                                    if (opennum[i].ToString() == selectnum[j].ToString())
                                    {
                                        if (j > i)
                                        {
                                            winNums.Add(num1 + "," + opennum[i].ToString());
                                        }

                                    }
                                }
                            }
                        }
                    }


                }
                else
                {
                    if (str1.Length < 2)
                    {
                        throw new ArgumentException("参数数格式不正确", "userChoseNumber");
                    }
                    if (str2.Length < 1)
                    {
                        throw new ArgumentException("参数数格式不正确", "userChoseNumber");
                    }
                    for (int i = 0; i < code.Length; i++)
                    {
                        for (int j = 0; j < code.Length; j++)
                        {
                            if (code[i].ToString() != code[j].ToString())
                            {
                                if (j > i)
                                {
                                    opennum.Add(code[i].ToString() + "," + code[j].ToString());
                                }
                            }
                        }
                    }
                    for (int i = 0; i < str1.Length; i++)
                    {
                        for (int j = 0; j < str1.Length; j++)
                        {
                            if (str1[i].ToString() != str1[j].ToString())
                            {
                                if (j != i)
                                {
                                    selectnum.Add(str1[i].ToString() + "," + str1[j].ToString());
                                }
                            }
                        }
                    }
                    for (int i = 0; i < opennum.Count; i++)
                    {
                        for (int j = 0; j < selectnum.Count; j++)
                        {
                            if (opennum[i].ToString() == selectnum[j].ToString())
                            {
                                for (int z = 0; z < code.Length; z++)
                                {
                                    for (int x = 0; x < str2.Length; x++)
                                    {
                                        if (str2[x].ToString() == code[i].ToString())
                                        {
                                            winNums.Add(opennum[i].ToString() + "," + code[z].ToString());
                                        }
                                    }

                                }
                            }
                        }
                    }
                }


            }
            return winNums;
        }
        protected override int _GetNumCount(string userChoseNumber)
        {
            var list = userChoseNumber.Split(new string[] { ",", "," }, StringSplitOptions.RemoveEmptyEntries);
            var num1 = list[0].ToString();
            String[] str1 = num1.Split(' ');
            var num2 = list[1].ToString();
            string[] str2 = num2.Split(' ');
            var result = 0;
            int count = str1.Length;
            int counynum = str2.Length;
            if (str1.Count() > 2 || str2.Count() + str1.Count() < 4 || str1.Count() == 0)
            {
                throw new ValidateException("选择的号码不正确！");
            }
            if (count == 1 && counynum > 1)
            {
                var n = 1;
                for (var a = counynum - 1; a <= counynum; a++)
                {
                    n = n * a;
                }
                var m = 1;
                for (var i = 1; i < 3; i++)
                {
                    m = m * i;
                }
                result = n / m;

            }
            if (count == 2 && counynum > 0)
            {
                result = counynum;
            }
            if (count == 0 || (counynum + count) < 3)
            {
                result = 0;
            }
            return count;
        }
        protected override List<string> _GetChoseNumberList(string userChoseNumber)
        {
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            if (base.lotteryType == LotteryType.TC11X5)
            {
                userChoseNumber = userChoseNumber.Replace("10", "a").Replace("11", "b").Replace("0", "").Replace(" ", "");
                base.ChoseNumberList = ManipulateNumber.GetNumList(userChoseNumber).Select(p => string.Join(" ", p.Select(pp => pp == 'a' || pp == 'b' ? pp.ToString() : "0" + pp).ToArray()).Replace("b", "11").Replace("a", "10")).ToList();
            }
            else
                base.ChoseNumberList = ManipulateNumber.GetNumList(userChoseNumber);
            return base.ChoseNumberList;
        }
    }


    /// <summary>
    ///"任四胆拖"
    /// </summary>
    internal class RenSiDanTuo : PlayTypeProduct
    {
        private string _OpenCode;
        private PlayType_E PlayType { get; set; }
        /// <summary>
        /// 数字的构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        public RenSiDanTuo(Regex regDouble)
            : base(regDouble)
        {
            PlayType = PlayType_E.RenSiDanTuo;
        }
        public RenSiDanTuo(Regex regDouble, PlayType_E playType)
            : base(regDouble)
        {
            PlayType = playType;
        }
        protected override IEnumerable<string> _GetWinNums(string userChoseNumber, string openCode)
        {
            _OpenCode = PlayType_E.RenSiDanTuo.GetOpenCode(openCode, base.lotteryType);
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            List<string> winNums = new List<string>();
            List<string> selectnum = new List<string>();
            List<string> opennum = new List<string>();
            List<string> dan = new List<string>();
            var num = 0;
            var list = userChoseNumber.Split(new string[] { ",", "," }, StringSplitOptions.RemoveEmptyEntries);
            var code = openCode.Split(new string[] { ",", "," }, StringSplitOptions.RemoveEmptyEntries);
            foreach (var item in list)
            {
                num++;
            }
            if (num == 1)
            {
                throw new ArgumentException("参数数格式不正确", "userChoseNumber");
            }
            else
            {
                var num1 = list[0].ToString();
                var str1 = num1.Split(' ');
                var num2 = list[1].ToString();
                var str2 = num2.Split(' ');


                if (str1.Length == 1)
                {
                    if (str2.Length < 3)
                    {
                        throw new ArgumentException("参数数格式不正确", "userChoseNumber");
                    }


                    for (int z = 0; z < code.Length; z++)
                    {
                        if (num1 == code[z].ToString())
                        {
                            for (int i = 0; i < code.Length; i++)
                            {
                                for (int j = 0; j < code.Length; j++)
                                {
                                    for (int x = 0; x < code.Length; x++)
                                    {
                                        if (code[i].ToString() != code[j].ToString() && code[i].ToString() != code[x].ToString() && code[j].ToString() != code[x].ToString())
                                        {
                                            if (x > j && j > i)
                                            {

                                                opennum.Add(code[i].ToString() + "," + code[j].ToString() + "," + code[x].ToString());
                                            }
                                        }
                                    }
                                }
                            }
                            for (int i = 0; i < str2.Length; i++)
                            {
                                for (int j = 0; j < str2.Length; j++)
                                {
                                    for (int x = 0; x < str2.Length; x++)
                                    {
                                        if (str2[i].ToString() != str2[j].ToString() && str2[i].ToString() != str2[x].ToString() && str2[j].ToString() != str2[x].ToString())
                                        {

                                            selectnum.Add(str2[i].ToString() + "," + str2[j].ToString() + "," + str2[x].ToString());

                                        }
                                    }
                                }
                            }
                            for (int i = 0; i < opennum.Count; i++)
                            {
                                for (int j = 0; j < selectnum.Count; j++)
                                {
                                    if (opennum[i].ToString() == selectnum[j].ToString())
                                    {
                                        winNums.Add(num1 + "," + opennum[i].ToString());
                                    }
                                }
                            }

                        }
                      
                    }


                }
                else if (str1.Length == 2)
                {
                    if (str1.Length < 2)
                    {
                        throw new ArgumentException("参数数格式不正确", "userChoseNumber");
                    }

                    for (int i = 0; i < code.Length; i++)
                    {
                        for (int j = 0; j < code.Length; j++)
                        {
                            if (code[i].ToString() != code[j].ToString())
                            {
                                if (j > i)
                                {
                                    opennum.Add(code[i].ToString() + "," + code[j].ToString());
                                }
                            }
                        }
                    }
                    for (int i = 0; i < str1.Length; i++)
                    {
                        for (int j = 0; j < str1.Length; j++)
                        {
                            if (str1[i].ToString() != str1[j].ToString())
                            {
                                selectnum.Add(str1[i].ToString() + "," + str1[j].ToString());
                            }
                        }
                    }
                    for (int i = 0; i < str2.Length; i++)
                    {
                        for (int j = 0; j < str2.Length; j++)
                        {
                            if (str2[i].ToString() != str2[j].ToString())
                            {
                                dan.Add(str2[i].ToString() + "," + str2[j].ToString());
                            }
                        }
                    }
                    for (int i = 0; i < opennum.Count; i++)
                    {
                        for (int j = 0; j < selectnum.Count; j++)
                        {
                            if (opennum[i].ToString() == selectnum[j].ToString())
                            {
                                for (int x = 0; x < opennum.Count; x++)
                                {
                                    for (int y = 0; y < dan.Count; y++)
                                    {
                                        if (opennum[x].ToString() == dan[y].ToString())
                                        {
                                            winNums.Add(opennum[i].ToString() + "," + dan[y].ToString());
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                else if (str1.Length == 3)
                {
                    Split sp = new Split();

                    selectnum = sp.San(str1, 0);
                    opennum = sp.San(code, 1);
                    List<string> li = sp.Pan(selectnum, opennum);
                    if (li.Count != 0)
                    {
                        for (int i = 0; i < code.Length; i++)
                        {
                            for (int j = 0; j < str2.Length; j++)
                            {
                                if (code[i].ToString() == str2[j].ToString())
                                {
                                    for (int x = 0; x < li.Count; x++)
                                    {
                                        winNums.Add(li[x].ToString() + "," + str2[j].ToString());
                                    }
                                }
                            }
                        }
                    }

                }


            }
            return winNums;
        }
        protected override int _GetNumCount(string userChoseNumber)
        {
            var list = userChoseNumber.Split(new string[] { ",", "," }, StringSplitOptions.RemoveEmptyEntries);
            var num1 = list[0].ToString();
            String[] str1 = num1.Split(' ');
            var num2 = list[1].ToString();
            string[] str2 = num2.Split(' ');
            int result = 0;
            int count = str1.Length;
            int counynum = str2.Length;
            if (str1.Count() > 3 || str2.Count() + str1.Count() < 5 || str1.Count() == 0)
            {
                throw new ValidateException("选择的号码不正确！");
            }
            if (count == 1 && counynum > 2)
            {
                var n = 1;
                for (var a = counynum - 2; a <= counynum; a++)
                {
                    n = n * a;
                }
                var m = 1;
                for (var i = 1; i < 4; i++)
                {
                    m = m * i;
                }
                result = n / m;

            }
            if (count == 2 && counynum > 1)
            {
                var n = 1;
                for (var a = counynum - 1; a <= counynum; a++)
                {
                    n = n * a;
                }
                var m = 1;
                for (var i = 1; i < 3; i++)
                {
                    m = m * i;
                }
                result = n / m;
            }
            if (count == 3 && counynum > 0)
            {
                result = counynum;
            }
            if ((count == 0) || ((count + counynum) < 4))
            {
                result = 0;
            }
            return result;
        }
        protected override List<string> _GetChoseNumberList(string userChoseNumber)
        {
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            if (base.lotteryType == LotteryType.TC11X5)
            {
                userChoseNumber = userChoseNumber.Replace("10", "a").Replace("11", "b").Replace("0", "").Replace(" ", "");
                base.ChoseNumberList = ManipulateNumber.GetNumList(userChoseNumber).Select(p => string.Join(" ", p.Select(pp => pp == 'a' || pp == 'b' ? pp.ToString() : "0" + pp).ToArray()).Replace("b", "11").Replace("a", "10")).ToList();
            }
            else
                base.ChoseNumberList = ManipulateNumber.GetNumList(userChoseNumber);
            return base.ChoseNumberList;
        }
    }


    /// <summary>
    /// "任五拖胆"
    /// </summary>
    internal class RenWuDanTuo : PlayTypeProduct
    {
        private string _OpenCode;
        private PlayType_E PlayType { get; set; }
        /// <summary>
        /// 数字的构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        public RenWuDanTuo(Regex regDouble)
            : base(regDouble)
        {
            PlayType = PlayType_E.RenWuDanTuo;
        }
        public RenWuDanTuo(Regex regDouble, PlayType_E playType)
            : base(regDouble)
        {
            PlayType = playType;
        }
        protected override IEnumerable<string> _GetWinNums(string userChoseNumber, string openCode)
        {
            _OpenCode = PlayType_E.RenWuDanTuo.GetOpenCode(openCode, base.lotteryType);
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");

            List<string> winNums = new List<string>();
            List<string> selectnum = new List<string>();
            List<string> opennum = new List<string>();
            List<string> dan = new List<string>();
            Split sp = new Split();
            var num = 0;
            var list = userChoseNumber.Split(new string[] { ",", "," }, StringSplitOptions.RemoveEmptyEntries);
            var code = openCode.Split(new string[] { ",", "," }, StringSplitOptions.RemoveEmptyEntries);
            foreach (var item in list)
            {
                num++;
            }
            if (num == 1)
            {
                throw new ArgumentException("参数数格式不正确", "userChoseNumber");
            }
            else
            {
                var num1 = list[0].ToString();
                var str1 = num1.Split(' ');
                var num2 = list[1].ToString();
                var str2 = num2.Split(' ');



                if (str1.Length == 1)
                {
                    if (str2.Length < 4)
                    {
                        throw new ArgumentException("参数数格式不正确", "userChoseNumber");
                    }
                    for (int z = 0; z < code.Length; z++)
                    {
                        if (num1 == code[z].ToString())
                        {
                            for (int i = 0; i < code.Length; i++)
                            {
                                for (int j = 0; j < code.Length; j++)
                                {
                                    for (int x = 0; x < code.Length; x++)
                                    {
                                        for (int y = 0; y < code.Length; y++)
                                        {
                                            if (code[i].ToString() != code[j].ToString() && code[i].ToString() != code[x].ToString() && code[j].ToString() != code[x].ToString() && code[x].ToString() != code[y].ToString() && code[j].ToString() != code[y].ToString() && code[i].ToString() != code[y].ToString())
                                            {
                                                if (x > j && j > i && y > x)
                                                {
                                                    opennum.Add(code[i].ToString() + "," + code[j].ToString() + "," + code[x].ToString() + "," + code[y].ToString());
                                                }
                                            }
                                        }

                                    }
                                }
                            }
                            for (int i = 0; i < str2.Length; i++)
                            {
                                for (int j = 0; j < str2.Length; j++)
                                {
                                    for (int x = 0; x < str2.Length; x++)
                                    {
                                        for (int y = 0; y < str2.Length; y++)
                                        {
                                            if (str2[i].ToString() != str2[j].ToString() && str2[i].ToString() != str2[x].ToString() && str2[j].ToString() != str2[x].ToString() && str2[x].ToString() != str2[y].ToString() && str2[j].ToString() != str2[y].ToString() && str2[i].ToString() != str2[y].ToString())
                                            {

                                                selectnum.Add(str2[i].ToString() + "," + str2[j].ToString() + "," + str2[x].ToString() + "," + str2[y].ToString());

                                            }
                                        }

                                    }
                                }
                            }
                            for (int i = 0; i < opennum.Count; i++)
                            {
                                for (int j = 0; j < selectnum.Count; j++)
                                {
                                    if (opennum[i].ToString() == selectnum[j].ToString())
                                    {
                                        winNums.Add(num1 + "," + opennum[i].ToString());
                                    }
                                }
                            }
                        }
                    }

                }
                else if (str1.Length == 2)
                {
                    if (str2.Length < 3)
                    {
                        throw new ArgumentException("参数数格式不正确", "userChoseNumber");
                    }

                    selectnum = sp.Er(str1, 0);
                    opennum = sp.Er(code, 1);
                    List<string> tuo = sp.Pan(selectnum, opennum);
                    if (tuo.Count != 0)
                    {
                        for (int i = 0; i < tuo.Count; i++)
                        {
                            dan = sp.San(str2, 0);
                            List<string> OpenDan = sp.San(code, 1);
                            List<string> winDan = sp.Pan(dan, OpenDan);
                            if (winDan.Count != 0)
                            {
                                for (int x = 0; x < winDan.Count(); x++)
                                {
                                    winNums.Add(tuo[i].ToString() + "," + winDan[x].ToString());
                                }
                            }
                        }
                    }

                }
                else if (str1.Length == 3)
                {
                    if (str2.Length < 2)
                    {
                        throw new ArgumentException("参数数格式不正确", "userChoseNumber");
                    }
                    selectnum = sp.San(str1, 0);
                    opennum = sp.San(code, 1);
                    List<string> tuo = sp.Pan(selectnum, opennum);
                    if (tuo.Count != 0)
                    {
                        for (int i = 0; i < tuo.Count; i++)
                        {
                            dan = sp.Er(str2, 0);
                            List<string> OpenDan = sp.Er(code, 1);
                            List<string> winDan = sp.Pan(dan, OpenDan);
                            if (winDan.Count != 0)
                            {
                                for (int x = 0; x < winDan.Count(); x++)
                                {
                                    winNums.Add(tuo[i].ToString() + "," + winDan[x].ToString());
                                }
                            }
                        }
                    }
                }
                else if (str1.Length == 4)
                {
                    if (str2.Length < 1)
                    {
                        throw new ArgumentException("参数数格式不正确", "userChoseNumber");
                    }
                    for (int i = 0; i < code.Length; i++)
                    {
                        if (code[i].ToString() == str2[0].ToString())
                        {
                            selectnum = sp.Si(str1, 0);
                            opennum = sp.Si(code, 1);
                            List<string> tuo = sp.Pan(selectnum, opennum);
                            if (tuo.Count != 0)
                            {
                                for (int j = 0; j < tuo.Count; j++)
                                {

                                    winNums.Add(code[i].ToString() + "," + tuo[j].ToString());
                                }
                            }
                        }
                    }
                }
                else
                {
                    throw new ArgumentException("参数数格式不正确", "userChoseNumber");
                }
            }

            return winNums;
        }
        protected override int _GetNumCount(string userChoseNumber)
        {
            var list = userChoseNumber.Split(new string[] { ",", "," }, StringSplitOptions.RemoveEmptyEntries);
            var num1 = list[0].ToString();
            String[] str1 = num1.Split(' ');
            var num2 = list[1].ToString();
            string[] str2 = num2.Split(' ');
            int result = 0;
            int count = str1.Length;
            int counynum = str2.Length;
            if (str1.Count() > 4 || str2.Count() + str1.Count() < 6 || str1.Count() == 0)
            {
                throw new ValidateException("选择的号码格式不正确！");
            }
            if (count == 1 && counynum > 3)
            {
                var n = 1;
                for (var a = counynum - 3; a <= counynum; a++)
                {
                    n = n * a;
                }
                var m = 1;
                for (var i = 1; i < 5; i++)
                {
                    m = m * i;
                }
                result = n / m;
            }
            if (count == 2 && counynum > 2)
            {
                var n = 1;
                for (var a = counynum - 2; a <= counynum; a++)
                {
                    n = n * a;
                }
                var m = 1;
                for (var i = 1; i < 4; i++)
                {
                    m = m * i;
                }
                result = n / m;
            }
            if (count == 3 && counynum > 1)
            {
                var n = 1;
                for (var a = counynum - 1; a <= counynum; a++)
                {
                    n = n * a;
                }
                var m = 1;
                for (var i = 1; i < 3; i++)
                {
                    m = m * i;
                }
                result = n / m;
            }
            if (count == 4 && counynum > 0)
            {
                result = counynum;
            }
            if (count == 0 || (count + counynum) < 5)
            {
                result = 0;
            }
            return result;
        }
        protected override List<string> _GetChoseNumberList(string userChoseNumber)
        {
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            if (base.lotteryType == LotteryType.TC11X5)
            {
                userChoseNumber = userChoseNumber.Replace("10", "a").Replace("11", "b").Replace("0", "").Replace(" ", "");
                base.ChoseNumberList = ManipulateNumber.GetNumList(userChoseNumber).Select(p => string.Join(" ", p.Select(pp => pp == 'a' || pp == 'b' ? pp.ToString() : "0" + pp).ToArray()).Replace("b", "11").Replace("a", "10")).ToList();
            }
            else
                base.ChoseNumberList = ManipulateNumber.GetNumList(userChoseNumber);
            return base.ChoseNumberList;
        }
    }



    /// <summary>
    /// 前一数投
    /// </summary>
    internal class QianYiShuTou : PlayTypeProduct
    {
        private string _OpenCode;
        private PlayType_E PlayType { get; set; }
        /// <summary>
        /// 数字的构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        public QianYiShuTou(Regex regDouble)
            : base(regDouble)
        {
            PlayType = PlayType_E.QianYiShuTou;
        }
        public QianYiShuTou(Regex regDouble, PlayType_E playType)
            : base(regDouble)
        {
            PlayType = playType;
        }
        protected override IEnumerable<string> _GetWinNums(string userChoseNumber, string openCode)
        {
            _OpenCode = PlayType_E.QianYiShuTou.GetOpenCode(openCode, base.lotteryType);
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");

            List<string> winNums = new List<string>();
            List<string> selectnum = new List<string>();
            List<string> opennum = new List<string>();
            var num = 0;
            var list = userChoseNumber.Replace(",", " ");

            foreach (var item in list)
            {
                num++;
            }
            if (num == 1)
            {
                throw new ArgumentException("参数数格式不正确", "userChoseNumber");
            }
            else
            {

                var ChoseNumber = userChoseNumber.Split(new string[] { ",", "," }, StringSplitOptions.RemoveEmptyEntries);

                var code = openCode.Split(new string[] { ",", "," }, StringSplitOptions.RemoveEmptyEntries);

                if (list.Length == 0)
                {
                    throw new ArgumentException("参数数格式不正确", "userChoseNumber");
                }
                string[] ls = list.Split(' ');
                for (int i = 0; i < ls.Length; i++)
                {
                    if (ls[i].ToString() == code[0].ToString())
                    {
                        winNums.Add(ls[i]);
                    }

                }


            }

            return winNums;
        }
        protected override int _GetNumCount(string userChoseNumber)
        {
            var list = userChoseNumber.Split(new string[] { ", ", "," }, StringSplitOptions.RemoveEmptyEntries);
            var num1 = list[0].ToString();
            int result = 0;
            String[] str1 = num1.Split(' ');
            if (list.Count() > 1)
            {
                var num2 = list[1].ToString();
                string[] str2 = num2.Split(' ');
                result = str2.Length + str1.Length;
            }
            else
            {
                result = str1.Length;
            }


            return result;
        }
        protected override List<string> _GetChoseNumberList(string userChoseNumber)
        {
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            if (base.lotteryType == LotteryType.TC11X5)
            {
                userChoseNumber = userChoseNumber.Replace("10", "a").Replace("11", "b").Replace("0", "").Replace(" ", "");
                base.ChoseNumberList = ManipulateNumber.GetNumList(userChoseNumber).Select(p => string.Join(" ", p.Select(pp => pp == 'a' || pp == 'b' ? pp.ToString() : "0" + pp).ToArray()).Replace("b", "11").Replace("a", "10")).ToList();
            }
            else
                base.ChoseNumberList = ManipulateNumber.GetNumList(userChoseNumber);
            return base.ChoseNumberList;
        }
    }



    /// <summary>
    /// "前一红投"
    /// </summary>
    internal class QianYiHongTou : PlayTypeProduct
    {
        private string _OpenCode;
        private PlayType_E PlayType { get; set; }
        /// <summary>
        /// 数字的构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        public QianYiHongTou(Regex regDouble)
            : base(regDouble)
        {
            PlayType = PlayType_E.QianYiHongTou;
        }
        public QianYiHongTou(Regex regDouble, PlayType_E playType)
            : base(regDouble)
        {
            PlayType = playType;
        }
        protected override IEnumerable<string> _GetWinNums(string userChoseNumber, string openCode)
        {
            _OpenCode = PlayType_E.QianYiHongTou.GetOpenCode(openCode, base.lotteryType);
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");

            List<string> winNums = new List<string>();
            List<string> selectnum = new List<string>();
            List<string> opennum = new List<string>();
            var num = 0;
            var list = userChoseNumber.Split(new string[] { ",", "," }, StringSplitOptions.RemoveEmptyEntries);
            foreach (var item in list)
            {
                num++;
            }
            if (num == 1)
            {
                throw new ArgumentException("参数数格式不正确", "userChoseNumber");
            }
            else
            {
                var ChoseNumber = userChoseNumber.Split(new string[] { ",", "," }, StringSplitOptions.RemoveEmptyEntries);
                var num1 = list[0].ToString();
                var num2 = list[1].ToString();
                var code = openCode.Split(new string[] { ",", "," }, StringSplitOptions.RemoveEmptyEntries);

                if (num1 == code[0].ToString())
                {
                    winNums.Add(num1.ToString());
                }
                if (num2 == code[0].ToString())
                {
                    winNums.Add(num1.ToString());
                }
            }

            return winNums;
        }
        protected override int _GetNumCount(string userChoseNumber)
        {
            if (userChoseNumber != "19,20")
            {
                return 0;
            }
            return 1;
        }
        protected override List<string> _GetChoseNumberList(string userChoseNumber)
        {
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            if (base.lotteryType == LotteryType.TC11X5)
            {
                userChoseNumber = userChoseNumber.Replace("10", "a").Replace("11", "b").Replace("0", "").Replace(" ", "");
                base.ChoseNumberList = ManipulateNumber.GetNumList(userChoseNumber).Select(p => string.Join(" ", p.Select(pp => pp == 'a' || pp == 'b' ? pp.ToString() : "0" + pp).ToArray()).Replace("b", "11").Replace("a", "10")).ToList();
            }
            else
                base.ChoseNumberList = ManipulateNumber.GetNumList(userChoseNumber);
            return base.ChoseNumberList;
        }
    }


    /// <summary>
    /// "选二连直"
    /// </summary>
    internal class XuanErLianZhi : PlayTypeProduct
    {
        private string _OpenCode;
        private PlayType_E PlayType { get; set; }
        /// <summary>
        /// 数字的构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        public XuanErLianZhi(Regex regDouble)
            : base(regDouble)
        {
            PlayType = PlayType_E.XuanErLianZhi;
        }
        public XuanErLianZhi(Regex regDouble, PlayType_E playType)
            : base(regDouble)
        {
            PlayType = playType;
        }

        protected override IEnumerable<string> _GetWinNums(string userChoseNumber, string openCode)
        {
            _OpenCode = PlayType_E.XuanErLianZhi.GetOpenCode(openCode, base.lotteryType);
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");

            //获奖号码
            List<string> winNums = new List<string>();
            //选择号码拆分
            List<string> selectnum = new List<string>();
            //开奖号码拆分
            List<string> opennum = new List<string>();
            //获取的用户选中的号码
            var list = userChoseNumber.Split(new string[] { ",", "," }, StringSplitOptions.RemoveEmptyEntries);
            var num1 = list[0];
            var num2 = list[1];
            string[] str1 = num1.Split(' ');
            string[] str2 = num2.Split(' ');
            int number = 0;
            foreach (var item in list)
            {
                number++;
            }
            if (number == 1)
            {
                throw new ArgumentException("参数数格式不正确", "userChoseNumber");
            }
            else
            {
                for (var i = 0; i < str1.Length; i++)
                {

                    for (var j = 0; j < str2.Length; j++)
                    {
                        if (str1[i] != str2[j])
                        {
                            selectnum.Add(str1[j].ToString() + "," + str2[i].ToString());
                        }


                    }

                }
                var open = openCode.Split(',');
                for (var i = 0; i < open.Length; i++)
                {
                    if (i > 0)
                    {
                        opennum.Add(open[i - 1] + "," + open[i]);
                    }
                }
            }

            for (int i = 0; i < opennum.Count; i++)
            {
                for (int j = 0; j < selectnum.Count; j++)
                {
                    if (opennum[i].ToString() == selectnum[j].ToString())
                    {
                        winNums.Add(opennum[i].ToString());
                    }
                }
            }

            return winNums;
        }
        protected override int _GetNumCount(string userChoseNumber)
        {
            var list = userChoseNumber.Split(new string[] { ", ", "," }, StringSplitOptions.RemoveEmptyEntries);
            var num1 = list[0].ToString();
            String[] str1 = num1.Split(' ');
            var num2 = list[1].ToString();
            string[] str2 = num2.Split(' ');
            int result1 = str1.Length;
            int result2 = str2.Length;
            int count = 0;
            if (result1 == 0 || result2 == 0)
            {
                count = 0;
            }
            else
            {

                for (var i = 0; i < result1; i++)
                {
                    for (var j = 0; j < result2; j++)
                    {
                        if (num1.Split(' ')[i].ToString() != num2.Split(' ')[j].ToString())
                            count += 1;
                    }
                }

            }
            return count;
        }

        protected override List<string> _GetChoseNumberList(string userChoseNumber)
        {
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            if (base.lotteryType == LotteryType.TC11X5)
            {
                userChoseNumber = userChoseNumber.Replace("10", "a").Replace("11", "b").Replace("0", "").Replace(" ", "");
                base.ChoseNumberList = ManipulateNumber.GetNumList(userChoseNumber).Select(p => string.Join(" ", p.Select(pp => pp == 'a' || pp == 'b' ? pp.ToString() : "0" + pp).ToArray()).Replace("b", "11").Replace("a", "10")).ToList();
            }
            else
                base.ChoseNumberList = ManipulateNumber.GetNumList(userChoseNumber);
            return base.ChoseNumberList;
        }
    }


    /// <summary>
    /// " 选二连组"
    /// </summary>
    internal class XuanErLianZu : PlayTypeProduct
    {
        private string _OpenCode;
        private PlayType_E PlayType { get; set; }
        /// <summary>
        /// 数字的构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        public XuanErLianZu(Regex regDouble)
            : base(regDouble)
        {
            PlayType = PlayType_E.XuanErLianZu;
        }
        public XuanErLianZu(Regex regDouble, PlayType_E playType)
            : base(regDouble)
        {
            PlayType = playType;
        }
        protected override IEnumerable<string> _GetWinNums(string userChoseNumber, string openCode)
        {
            _OpenCode = PlayType_E.XuanErLianZu.GetOpenCode(openCode, base.lotteryType);
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");

            List<string> winNums = new List<string>();
            List<string> selectnum = new List<string>();
            List<string> opennum = new List<string>();
            List<string> dan = new List<string>();
            Split sp = new Split();
            userChoseNumber = userChoseNumber.Replace(',', ' ');
            var list = userChoseNumber.Split(new string[] { ",", "," }, StringSplitOptions.RemoveEmptyEntries);
            var code = openCode.Split(new string[] { ",", "," }, StringSplitOptions.RemoveEmptyEntries);
            string[] str1;
            if (list.Count() == 2)
            {
                userChoseNumber = userChoseNumber.Replace(',', ' ');
                str1 = userChoseNumber.Split(' ');
            }
            else
            {
                str1 = list[0].Split(' ');
            }
            selectnum = sp.Er(str1, 0);
            opennum = sp.LianEr(code);
            winNums = sp.Pan(selectnum, opennum);

            return winNums;
        }

        protected override int _GetNumCount(string userChoseNumber)
        {
            if (string.IsNullOrEmpty(userChoseNumber))
                throw new ArgumentNullException();
            if (base.lotteryType == LotteryType.TC11X5)
                userChoseNumber = userChoseNumber.Replace("10", "a").Replace("11", "b").Replace("0", "");

            userChoseNumber = userChoseNumber.Replace(" ", "");
            if (userChoseNumber.Replace(",", "").Length == 3)
                return 1;
            var list = userChoseNumber.Split(',');
            if (list.Length != 3)
                throw new ArgumentException();
            return list[0].Length * list[1].Length * list[2].Length;
        }
        protected override List<string> _GetChoseNumberList(string userChoseNumber)
        {
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            if (base.lotteryType == LotteryType.TC11X5)
            {
                userChoseNumber = userChoseNumber.Replace("10", "a").Replace("11", "b").Replace("0", "").Replace(" ", "");
                base.ChoseNumberList = ManipulateNumber.GetNumList(userChoseNumber).Select(p => string.Join(" ", p.Select(pp => pp == 'a' || pp == 'b' ? pp.ToString() : "0" + pp).ToArray()).Replace("b", "11").Replace("a", "10")).ToList();
            }
            else
                base.ChoseNumberList = ManipulateNumber.GetNumList(userChoseNumber);
            return base.ChoseNumberList;
        }

    }


    /// <summary>
    /// "选三前直"
    /// </summary>
    internal class XuanSanQianZhi : PlayTypeProduct
    {
        private string _OpenCode;
        private PlayType_E PlayType { get; set; }
        /// <summary>
        /// 数字的构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        public XuanSanQianZhi(Regex regDouble)
            : base(regDouble)
        {
            PlayType = PlayType_E.XuanSanQianZhi;
        }
        public XuanSanQianZhi(Regex regDouble, PlayType_E playType)
            : base(regDouble)
        {
            PlayType = playType;
        }

        protected override IEnumerable<string> _GetWinNums(string userChoseNumber, string openCode)
        {
            _OpenCode = PlayType_E.XuanSanQianZhi.GetOpenCode(openCode, base.lotteryType);
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");

            //获奖号码
            List<string> winNums = new List<string>();
            //选择号码拆分
            List<string> selectnum = new List<string>();
            //开奖号码拆分
            List<string> opennum = new List<string>();
            //获取的用户选中的号码
            var list = userChoseNumber.Split(new string[] { ",", "," }, StringSplitOptions.RemoveEmptyEntries);
           
            int number = 0;
            foreach (var item in list)
            {
                number++;
            }
            if (number < 3)
            {
                throw new ArgumentException("参数数格式不正确", "userChoseNumber");
            }
            else
            {
                var num1 = list[0];
                var num2 = list[1];
                var num3 = list[2];
                string[] str1 = num1.Split(' ');
                string[] str2 = num2.Split(' ');
                string[] str3 = num3.Split(' ');
                for (var i = 0; i < str1.Length; i++)
                {
                    for (int j = 0; j < str2.Length; j++)
                    {
                        for (int x = 0; x < str3.Length; x++)
                        {
                            if (str1[i] != str2[j] && str2[j] != str3[x] && str1[i] != str3[x])
                            {
                                selectnum.Add(str1[i].ToString() + "," + str2[j].ToString() + "," + str3[x].ToString());
                            }
                        }
                    }
                }
                string[] open = openCode.Split(',');
                opennum.Add(open[0] + "," + open[1] + "," + open[2]);

            }

            for (int i = 0; i < selectnum.Count; i++)
            {

                if (selectnum[i].ToString() == opennum[0].ToString())
                {
                    winNums.Add(opennum[0].ToString());
                }

            }

            return winNums;
        }
        protected override int _GetNumCount(string userChoseNumber)
        {
            var list = userChoseNumber.Split(new string[] { ",", "," }, StringSplitOptions.RemoveEmptyEntries);
            var num1 = list[0].ToString();
            String[] str1 = num1.Split(' ');
            var num2 = list[1].ToString();
            string[] str2 = num2.Split(' ');
            var num3 = list[2].ToString();
            string[] str3 = num3.Split(' ');

            int result1 = str1.Length;
            int result2 = str2.Length;
            int result3 = str3.Length;
            int count = 0;
            if (result1 == 0 || result2 == 0 || result3 == 0)
            {
                count = 0;
            }
            else
            {

                for (var i = 0; i < num1.Split(' ').Length; i++)
                {
                    for (var j = 0; j < num2.Split(' ').Length; j++)
                    {
                        for (var k = 0; k < num3.Split(' ').Length; k++)
                        {
                            if (num1.Split(' ')[i].ToString() != num2.Split(' ')[j].ToString() && num2.Split(' ')[j].ToString() != num3.Split(' ')[k].ToString() && num1.Split(' ')[i].ToString() != num3.Split(' ')[k].ToString())
                                count += 1;
                        }
                    }
                }

            }
            return count;
        }
        protected override List<string> _GetChoseNumberList(string userChoseNumber)
        {
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            if (base.lotteryType == LotteryType.TC11X5)
            {
                userChoseNumber = userChoseNumber.Replace("10", "a").Replace("11", "b").Replace("0", "").Replace(" ", "");
                base.ChoseNumberList = ManipulateNumber.GetNumList(userChoseNumber).Select(p => string.Join(" ", p.Select(pp => pp == 'a' || pp == 'b' ? pp.ToString() : "0" + pp).ToArray()).Replace("b", "11").Replace("a", "10")).ToList();
            }
            else
                base.ChoseNumberList = ManipulateNumber.GetNumList(userChoseNumber);
            return base.ChoseNumberList;
        }
    }



    /// <summary>
    /// "选三前组"
    /// </summary>
    internal class XuanSanQianZu : PlayTypeProduct
    {
        private string _OpenCode;
        private PlayType_E PlayType { get; set; }
        /// <summary>
        /// 数字的构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        public XuanSanQianZu(Regex regDouble)
            : base(regDouble)
        {
            PlayType = PlayType_E.XuanSanQianZu;
        }
        public XuanSanQianZu(Regex regDouble, PlayType_E playType)
            : base(regDouble)
        {
            PlayType = playType;
        }
        protected override IEnumerable<string> _GetWinNums(string userChoseNumber, string openCode)
        {
            _OpenCode = PlayType_E.XuanSanQianZu.GetOpenCode(openCode, base.lotteryType);
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");

            List<string> winNums = new List<string>();
            List<string> selectnum = new List<string>();
            List<string> opennum = new List<string>();
            List<string> dan = new List<string>();
            Split sp = new Split();
            userChoseNumber = userChoseNumber.Replace(',', ' ');
            var list = userChoseNumber.Split(new string[] { ",", "," }, StringSplitOptions.RemoveEmptyEntries);
            var code = openCode.Split(new string[] { ",", "," }, StringSplitOptions.RemoveEmptyEntries);
            var str1 = list[0].Split(' ');
            selectnum = sp.San(str1, 0);
            opennum = sp.QianSan(code);
            winNums = sp.Pan(selectnum, opennum);

            return winNums;
        }


        protected override int _GetNumCount(string userChoseNumber)
        {
            Split sp = new Split();
            userChoseNumber = userChoseNumber.Replace(',', ' ');
            var list = userChoseNumber.Split(new string[] { ",", "," }, StringSplitOptions.RemoveEmptyEntries);
            return sp.San(list, 0).Count();
        }
        protected override List<string> _GetChoseNumberList(string userChoseNumber)
        {
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            if (base.lotteryType == LotteryType.TC11X5)
            {
                userChoseNumber = userChoseNumber.Replace("10", "a").Replace("11", "b").Replace("0", "").Replace(" ", "");
                base.ChoseNumberList = ManipulateNumber.GetNumList(userChoseNumber).Select(p => string.Join(" ", p.Select(pp => pp == 'a' || pp == 'b' ? pp.ToString() : "0" + pp).ToArray()).Replace("b", "11").Replace("a", "10")).ToList();
            }
            else
                base.ChoseNumberList = ManipulateNumber.GetNumList(userChoseNumber);
            return base.ChoseNumberList;
        }
    }



    /// <summary>
    /// 选二连组胆拖
    /// </summary>
    internal class XuanErLianZuDanTuo : PlayTypeProduct
    {
        private string _OpenCode;
        private PlayType_E PlayType { get; set; }
        /// <summary>
        /// 数字的构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        public XuanErLianZuDanTuo(Regex regDouble)
            : base(regDouble)
        {
            PlayType = PlayType_E.XuanErLianZuDanTuo;
        }
        public XuanErLianZuDanTuo(Regex regDouble, PlayType_E playType)
            : base(regDouble)
        {
            PlayType = playType;
        }
        protected override IEnumerable<string> _GetWinNums(string userChoseNumber, string openCode)
        {
            _OpenCode = PlayType_E.XuanErLianZuDanTuo.GetOpenCode(openCode, base.lotteryType);
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");

            List<string> winNums = new List<string>();
            List<string> selectnum = new List<string>();
            List<string> opennum = new List<string>();
            List<string> dan = new List<string>();
            Split sp = new Split();

            var list = userChoseNumber.Split(new string[] { ",", "," }, StringSplitOptions.RemoveEmptyEntries);
            var code = openCode.Split(new string[] { ",", "," }, StringSplitOptions.RemoveEmptyEntries);
            if (list.Length != 2)
            {
                throw new ArgumentNullException("userChoseNumber", "参数格式不正确");
            }
            else
            {
                string[] str1 = list[0].Split(' ');
                string[] str2 = list[1].Split(' ');
                if (str1.Length != 1 || str2.Length < 2)
                {
                    throw new ArgumentNullException("userChoseNumber", "参数格式不正确");
                }
                for (int i = 0; i < code.Length; i++)
                {
                    if (str1[0].ToString() == code[i].ToString())
                    {

                        opennum = sp.LianEr(code);
                        for (int x = 0; x < str2.Length; x++)
                        {
                            selectnum.Add(str1[0].ToString() + "," + str2[x].ToString());
                        }
                        winNums = sp.Pan(selectnum, opennum);

                    }
                }
            }

            return winNums;
        }

        protected override int _GetNumCount(string userChoseNumber)
        {
            var list = userChoseNumber.Split(new string[] { ",", "," }, StringSplitOptions.RemoveEmptyEntries);
            var num1 = list[0].ToString();
            String[] str1 = num1.Split(' ');
            var num2 = list[1].ToString();
            string[] str2 = num2.Split(' ');
            int cout = 0;
            if (str1.Count() > 1 || str2.Count() + str1.Count() < 3 || str1.Count() == 0)
            {
                throw new ValidateException("选择的号码不正确！");
            }
            if (str1.Length == 0)
            {
                cout = 0;
            }
            else
            {
                cout = str2.Length;
            }
            return cout;
        }
        protected override List<string> _GetChoseNumberList(string userChoseNumber)
        {
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            if (base.lotteryType == LotteryType.TC11X5)
            {
                userChoseNumber = userChoseNumber.Replace("10", "a").Replace("11", "b").Replace("0", "").Replace(" ", "");
                base.ChoseNumberList = ManipulateNumber.GetNumList(userChoseNumber).Select(p => string.Join(" ", p.Select(pp => pp == 'a' || pp == 'b' ? pp.ToString() : "0" + pp).ToArray()).Replace("b", "11").Replace("a", "10")).ToList();
            }
            else
                base.ChoseNumberList = ManipulateNumber.GetNumList(userChoseNumber);
            return base.ChoseNumberList;
        }

    }



    /// <summary>
    /// "选三前组胆拖"
    /// </summary>
    internal class XuanSanQianZuDanTuo : PlayTypeProduct
    {
        private string _OpenCode;
        private PlayType_E PlayType { get; set; }
        /// <summary>
        /// 数字的构造函数
        /// </summary>
        /// <param name="regDouble">复式的号码格式</param>
        public XuanSanQianZuDanTuo(Regex regDouble)
            : base(regDouble)
        {
            PlayType = PlayType_E.XuanSanQianZuDanTuo;
        }
        public XuanSanQianZuDanTuo(Regex regDouble, PlayType_E playType)
            : base(regDouble)
        {
            PlayType = playType;
        }
        protected override IEnumerable<string> _GetWinNums(string userChoseNumber, string openCode)
        {
            _OpenCode = PlayType_E.XuanSanQianZuDanTuo.GetOpenCode(openCode, base.lotteryType);
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");

            List<string> winNums = new List<string>();
            List<string> selectnum = new List<string>();
            List<string> opennum = new List<string>();
            List<string> dan = new List<string>();
            Split sp = new Split();

            var list = userChoseNumber.Split(new string[] { ",", "," }, StringSplitOptions.RemoveEmptyEntries);
            var code = openCode.Split(new string[] { ",", "," }, StringSplitOptions.RemoveEmptyEntries);
            if (list.Length != 2)
            {
                throw new ArgumentNullException("userChoseNumber", "参数格式不正确");
            }
            else
            {
                string[] str1 = list[0].Split(' ');
                string[] str2 = list[1].Split(' ');
                if (str1.Length > 2 || str2.Length < 2)
                {
                    throw new ArgumentNullException("userChoseNumber", "参数格式不正确");
                }
                if (str1.Length == 1)
                {
                    List<string> sel = new List<string>();
                    for (int i = 0; i < code.Length; i++)
                    {
                        if (str1[0].ToString() == code[i].ToString())
                        {
                            selectnum = sp.Er(str2, 1);
                            for (int j = 0; j < selectnum.Count(); j++)
                            {

                                sel.Add(str1[0].ToString() + "," + selectnum[j].ToString());
                            }

                            string open = code[0].ToString() + "," + code[1].ToString() + "," + code[2].ToString();
                            string[] win = open.Split(',');
                            opennum = sp.San(win, 0);
                            winNums = sp.Pan(opennum, sel);
                        }
                    }
                }
                else
                {
                    selectnum = sp.Er(str1, 0);
                    opennum = sp.Er(code, 1);
                    List<string> li = sp.Pan(selectnum, opennum);

                    if (li != null)
                    {
                        string open = code[0].ToString() + "," + code[1].ToString() + "," + code[2].ToString();
                        string[] win = open.Split(',');
                        opennum = sp.San(win, 0);
                        List<string> sel = new List<string>();
                        for (int i = 0; i < str2.Length; i++)
                        {
                            sel.Add(str1[0].ToString() + "," + str1[1].ToString() + "," + str2[i].ToString());
                        }
                        winNums = sp.Pan(sel, opennum);
                    }
                }

            }
            return winNums;
        }

        protected override int _GetNumCount(string userChoseNumber)
        {
            var list = userChoseNumber.Split(new string[] { ",", "," }, StringSplitOptions.RemoveEmptyEntries);
            var num1 = list[0].ToString();
            String[] str1 = num1.Split(' ');
            var num2 = list[1].ToString();
            string[] str2 = num2.Split(' ');
            var result = 0;
            int count = str1.Length;
            int counynum = str2.Length;
            if (str1.Count() > 2 || str2.Count() + str1.Count() < 4 || str1.Count() == 0)
            {
                throw new ValidateException("选择的号码不正确！");
            }
            if (count == 1 && counynum > 1)
            {
                var n = 1;
                for (var a = counynum - 1; a <= counynum; a++)
                {
                    n = n * a;
                }
                var m = 1;
                for (var i = 1; i < 3; i++)
                {
                    m = m * i;
                }
                result = n / m;

            }
            if (count == 2 && counynum > 0)
            {
                result = counynum;
            }
            if (count == 0 || (counynum + count) < 3)
            {
                result = 0;
            }
            return result;
        }
        protected override List<string> _GetChoseNumberList(string userChoseNumber)
        {
            if (userChoseNumber == null)
                throw new ArgumentNullException("userChoseNumber", "参数不能为空");
            if (base.lotteryType == LotteryType.TC11X5)
            {
                userChoseNumber = userChoseNumber.Replace("10", "a").Replace("11", "b").Replace("0", "").Replace(" ", "");
                base.ChoseNumberList = ManipulateNumber.GetNumList(userChoseNumber).Select(p => string.Join(" ", p.Select(pp => pp == 'a' || pp == 'b' ? pp.ToString() : "0" + pp).ToArray()).Replace("b", "11").Replace("a", "10")).ToList();
            }
            else
                base.ChoseNumberList = ManipulateNumber.GetNumList(userChoseNumber);
            return base.ChoseNumberList;
        }

    }



    public class Split
    {
        public List<string> Er(string[] num, int cout)
        {
            List<string> list = new List<string>();
            for (int i = 0; i < num.Length; i++)
            {
                for (int j = 0; j < num.Length; j++)
                {
                    if (num[i].ToString() != num[j].ToString())
                    {
                        if (cout == 0)
                        {
                            list.Add(num[i].ToString() + "," + num[j].ToString());
                        }
                        else
                        {
                            if (j > i)
                            {
                                list.Add(num[i].ToString() + "," + num[j].ToString());
                            }
                        }


                    }
                }
            }
            return list;
        }
        public List<string> San(string[] num, int cout)
        {
            List<string> list = new List<string>();
            for (int i = 0; i < num.Length; i++)
            {
                for (int j = 0; j < num.Length; j++)
                {
                    for (int x = 0; x < num.Length; x++)
                    {
                        if (num[i].ToString() != num[j].ToString() && num[j].ToString() != num[x].ToString() && num[i].ToString() != num[x].ToString())
                        {
                            if (cout == 0)
                            {
                                list.Add(num[i].ToString() + "," + num[j].ToString() + "," + num[x].ToString());

                            }
                            else
                            {
                                if (j > i && x > j)
                                {
                                    list.Add(num[i].ToString() + "," + num[j].ToString() + "," + num[x].ToString());

                                }
                            }

                        }
                    }

                }
            }
            return list;
        }
        public List<string> Si(string[] num, int cout)
        {
            List<string> list = new List<string>();
            for (int i = 0; i < num.Length; i++)
            {
                for (int j = 0; j < num.Length; j++)
                {
                    for (int x = 0; x < num.Length; x++)
                    {
                        for (int y = 0; y < num.Length; y++)
                        {
                            if (num[i].ToString() != num[j].ToString() && num[j].ToString() != num[x].ToString() && num[i].ToString() != num[x].ToString() && num[i].ToString() != num[y].ToString() && num[j].ToString() != num[y].ToString() && num[x].ToString() != num[y].ToString())
                            {
                                if (cout == 0)
                                {
                                    list.Add(num[i].ToString() + "," + num[j].ToString() + "," + num[x].ToString() + "," + num[y].ToString());

                                }
                                else
                                {
                                    if (j > i)
                                    {
                                        list.Add(num[i].ToString() + "," + num[j].ToString() + "," + num[x].ToString() + "," + num[y].ToString());

                                    }
                                }

                            }
                        }

                    }

                }
            }
            return list;

        }
        public List<string> LianEr(string[] num)
        {
            List<string> list = new List<string>();
            for (int i = 0; i < num.Length; i++)
            {
                if (i > 0)
                {
                    list.Add(num[i - 1] + "," + num[i]);
                }
            }
            return list;
        }
        public List<string> QianSan(string[] num)
        {
            List<string> list = new List<string>();
            for (int i = 0; i < num.Length; i++)
            {
                if (i == 0)
                {
                    list.Add(num[i].ToString() + "," + num[i + 1].ToString() + "," + num[i + 2].ToString());
                }
            }
            return list;
        }

        public List<string> Pan(List<string> num, List<string> num1)
        {
            List<string> list = new List<string>();
            for (int i = 0; i < num.Count(); i++)
            {
                for (int j = 0; j < num1.Count(); j++)
                {
                    if (num[i].ToString() == num1[j].ToString())
                    {

                        list.Add(num[i].ToString());

                    }
                }
            }
            return list;
        }
    }

}


